﻿function imageResize(size, id) {
    var img = document.getElementById(id);
    
    var width = img.clientWidth;
    var height = img.clientHeight;
    if(width >= height)
    {
        // If the width is greater than the height
        // we must center vertically.
        img.width = size;
        height = img.clientHeight;
        var imgMargin = (size - height)/2;
        img.style.marginTop = imgMargin + "px";
    }
    else 
    {   
        // If the height is greater than the width
        // we must center horizontally. 
        img.height = size;
        width = img.clientWidth;
        var imgMargin = (size - width)/2;
        img.style.marginLeft = imgMargin + "px";
    }
    img.style.visibility = 'visible';
}
